********************************************************************
Sub fineQuad()

' cerca nelle giustificazioni se c' il n. 90 ( es: Trasferta) 
'e aggiunge un minuto di 168 (es: Trasferta in GG) 
'n.b. l'uso di cl.DataElab2


Set RsGiust = cl.miodb.openrecordset("SELECT * FROM giustificazioni WHERE (id_dip=" & cl.DipElab & " and dta =# " & cl.DataElab2  & "#);",4) 
   '* guarda se c' il 90
   flagTrovato=0 ' imposta per non trovato

   If RsGiust.RecordCount > 0 Then
      RsGiust.MoveLast ' altrimenti recordcount non funge
      RsGiust.MoveFirst
      For x = 0 To RsGiust.RecordCount - 1
         m_idgiust = RsGiust.Fields("id_giust") ' id del tipo di giustificativo
         if m_idgiust=90 then
           flagTrovato = 1
           exit for  ' esci dal ciclo
         end if        
         RsGiust.MoveNext
      Next
   End If

RsGiust.close

if flagTrovato =1 then
  set RsGiu = cl.miodb.openrecordset("giustificazioni", 1) ' 1 = dbOpenTable

   RsGiu.index = "tot_g"
   RsGiu.seek "=",168, cl.dataelab, cl.dipelab
 
   if RsGiu.NoMatch then
      RsGiu.AddNew 
   else
      RsGiu.edit  
   end if
   RsGiu.fields("auto") = True
   RsGiu.fields("id_giust") = 168  ' GG Trasferta
   RsGiu.fields("id_dip") = cl.DipElab
   RsGiu.fields("dta") = cl.DataElab
   RsGiu.fields("minuti") = 1  ' perch segni un Giorno
   RsGiu.Update
   RsGiu.close
end if

End Sub

********************************************************************

********************************************************************
sub Iniquad()
' modifica la 3a timbratura calcolata se  prima delle 14.00 diventa 14.00 dal 1 Ottobre 2002 in poi


if not cl.flagBlG  then ' non fare se c' il blocco giustif
Select Case cl.OrarioElab ' in base al tipo di orario


Case  6 ' impiegati

if datediff("d","01/10/2002",cl.dataelab) >= 0 then 'solo dal 01/10/2002 in poi

if cl.cltimborig3 < "14.00.00" and cl.cltimborig3 <> "0.00.00" then
  cl.cltimb3 ="14.00.00"
end if
end if
end select

end if 
End sub

*****************************************************************

********************************************************************
sub Iniquad()
' modifica la 1a timbratura calcolata se  dalle 8.01 alle 8.05 diventa 8.00


if cl.cltimborig1 >"8.00.00" and cl.cltimborig1 < "8.06.00" then
  cl.cltimb1 ="8.00.00"
end if

 
End sub
*****************************************************************

********************************************************************
sub IniAutoStra()
'  se fa 25 minuti di presenza diventa mezzora


'a= msgbox ("esci ?",vbyesno)
'if a= vbyes then exit sub

' calcola la presenza effettiva
mtotpres=0

mTotPres =mTotPres + DateDiff("n", cltimborig1, cltimborig2)
mTotPres =mTotPres + DateDiff("n", cltimborig3, cltimborig4)
mTotPres =mTotPres + DateDiff("n", cltimborig5, cltimborig6)
mTotPres =mTotPres + DateDiff("n", cltimborig7, cltimborig8)


if mtotpres mod 30 > 24 then  
   
   QuadGio = QuadGio + 30        ' scrivere quadgio equivale a cl.quadgio
    TotPres = TotPres +30            '   idem per totpres
  anomalie = anomalie or 128    '   idem per anomalie
end if



End sub
*****************************************************************

*****************************************************************
Sub fineQuad()

' cerca nelle giustificazioni se c' il n. 93 (pausa lavoro) e aggiunge una anomalia generica se supera i 15 minuti 
'n.b. l'uso di cl.DataElab2


Set RsGiust = cl.miodb.openrecordset("SELECT * FROM giustificazioni WHERE (id_dip=" & cl.DipElab & " and dta =# " & cl.DataElab2  & "#);",4) 
   '* guarda se c' il 93
   
   If RsGiust.RecordCount > 0 Then
      RsGiust.MoveLast ' altrimenti recordcount non funge
      RsGiust.MoveFirst
      For x = 0 To RsGiust.RecordCount - 1
         m_idgiust = RsGiust.Fields("id_giust") ' id del tipo di giustificativo
         m_ore = RsGiust.Fields("minuti")
         if m_idgiust=93 and m_ore > 15 then cl.anomalie = cl.anomalie or 128        
         RsGiust.MoveNext
      Next
   End If

End Sub

*****************************************************************

*****************************************************************


sub fineRegTot()
'si possono aggiungere dei totali che si vedono nel cartellino
'n.b. l'uso di cl.DataElab (nei seek) e di cl.DataElab2 (nelle query)


' max 45 ore  VEDI ANCHE SUB IniAutoStra()

if weekday(cl.dataelab) = 1 then  ' solo se  domenica
soglia=2700   ' = 45 ore
idG = 178     ' = > 45 ore

Da = DateAdd("d", -6 ,cl.dataelab )  '  cl.dataelab - 6  = il luned precedente

DataElabDal = mid(da,4,2) & "/" & left(da,2) & "/"  & right(da,4) ' trasformo in formato americano per la query


set RsTot = cl.MioDb.OpenRecordset("SELECT sum(totale) as [totalone] FROM totali WHERE ((id_giust = 13 or id_giust = 15) and id_dip=" & cl.DipElab & " and data >=# " & DataElabDal & "# and data <=# " & DataElab2 & "#);", 4)

totaleMin = rsTot.fields("totalone")

if totaleMin > soglia then 
   totaleMin = totaleMin - soglia
   set RsTot = cl.miodb.openrecordset("totali", 1) ' 1 = dbOpenTable

   RsTot.index = "totali"
   RsTot.seek "=",cl.dipelab, cl.dataelab, idG
 
   if RsTot.NoMatch then
      RsTot.AddNew 
   else
      RsTot.edit  
   end if
   RsTot.fields("flagok") = True
   RsTot.fields("id_giust") = idG  ' >45 ore
   RsTot.fields("id_dip") = cl.DipElab
   RsTot.fields("data") = cl.DataElab
   RsTot.fields("totale") = totaleMin  ' perch segni in ore
   RsTot.Update
end if


RsTot.close


end if  ' se  domenica

end sub
*****************************************************************

*****************************************************************
sub IniAutoStra()

' max 45 ore Versione che visualizza anche nelle giust del giorno

if weekday(cl.dataelab) = 1 then  ' solo se  domenica
 soglia=2700   ' = 45 ore
 idG = 172     ' = > 45 ore

 Da = DateAdd("d", -6 ,cl.dataelab )  '  cl.dataelab - 6  = il luned precedente
 al = DateAdd("d",-1,cl.DataElab)

 mDataElabDal = mid(da,4,2) & "/" & left(da,2) & "/"  & right(da,4) ' trasformo in formato americano per la query
 mDataElabal = mid(al,4,2) & "/" & left(al,2) & "/"  & right(al,4) ' 
 
 set RsTot = cl.MioDb.OpenRecordset("SELECT sum(totale) as [totalone] FROM totali WHERE ((id_giust = 13 or id_giust = 15) and id_dip=" & cl.DipElab & " and data >=# " & mDataElabDal & "# and data <=# " & mdataelabal & "#);", 4)

 totaleMin = rsTot.fields("totalone")

 if totaleMin > soglia and cl.flagBlG = false then 
   totaleMin = totaleMin - soglia
   ' aggiunta
   set RsGiu = cl.miodb.openrecordset("giustificazioni", 1) ' 1 = dbOpenTable

   RsGiu.index = "tot_g"
   RsGiu.seek "=",idG, cl.dataelab, cl.dipelab
 
   if RsGiu.NoMatch then
      RsGiu.AddNew 
   else
      RsGiu.edit  
   end if
   RsGiu.fields("auto") = True
   RsGiu.fields("id_giust") = idG  ' >45 ore
   RsGiu.fields("id_dip") = cl.DipElab
   RsGiu.fields("dta") = cl.DataElab
   RsGiu.fields("minuti") = totaleMin  ' perch segni in ore
   RsGiu.Update
   ' fine aggiunta
 end if
end if


end sub
*****************************************************************

*****************************************************************
sub fineRegTot()
'si possono aggiungere dei totali che si vedono nel cartellino
'n.b. l'uso di cl.DataElab e di cl.DataElab2

Set RsGiust = cl.miodb.openrecordset("SELECT * FROM giustificazioni WHERE (id_dip=" & cl.DipElab & " and dta =# " & cl.DataElab2  & "#);",4) 

Set RsTotali = cl.miodb.openrecordset("totali", 1) ' 1 = dbOpenTable

If cl.QuadGio = 0 Then flag = True

   '* guarda se c' il 93
   If RsGiust.RecordCount > 0 Then
      RsGiust.MoveLast ' altrimenti recordcount non funge
      RsGiust.MoveFirst
      For x = 0 To RsGiust.RecordCount - 1
         m_idgiust = RsGiust.Fields("id_giust") ' id del tipo di giustificativo
         m_ore = RsGiust.Fields("minuti")
        
         ' se ci sono ferie aggiungi ferie in gg       
         if m_idgiust=16 then  ' 16 = ferie
           RsTotali.index = "totali"
           RsTotali.seek "=",cl.dipelab, cl.dataelab, 150
           if RsTotali.NoMatch then
              RsTotali.AddNew    
           else
              RsTotali.edit  
           end if
           RsTotali.fields("flagok") = True
           RsTotali.fields("id_giust") = 158  ' ferie in gg
           RsTotali.fields("id_dip") = cl.DipElab
           RsTotali.fields("data") = cl.DataElab
           RsTotali.fields("totale") = 60 ' perch segni i ferie in GG come ore
           RsTotali.Update
         End if
        
  
         RsGiust.MoveNext
      Next
   End If

rsgiust.close
RsTotali.close


end sub

*****************************************************************
sub IniAutoStra()
' si pu variare cl.quadgio e, di conseguenza, cl.totpres


' toglie fino a 10 minuti di straordinario 
if cl.quadgio > 0 then
 If cl.QuadGio > 10 Then
   cl.QuadGio = cl.QuadGio - 10 ' toglie i primi 10 min di straord.
   cl.TotPres = cl.TotPres - 10
 Else
   cl.TotPres = cl.TotPres - cl.QuadGio
   cl.QuadGio = 0
 End If
end if

end sub
*****************************************************************

*****************************************************************
sub IniAutoStra()

Select Case cl.OrarioElab ' in base al tipo di orario

' notare come si usa il case !!!

Case  5 ' forfettari nessun straordinario
  If cl.QuadGio > 0 Then
    cl.TotPres = cl.TotPres - cl.QuadGio
    cl.QuadGio = 0
  End If

Case  1  ' giornalieri
 ' toglie fino a 10 minuti di straordinario
   If cl.QuadGio > 0 Then
     If cl.QuadGio > 10 Then
       cl.QuadGio = cl.QuadGio - 10 ' toglie i primi 10 min di straord.
       cl.TotPres = cl.TotPres - 10
     Else
       cl.TotPres = cl.TotPres - cl.QuadGio
       cl.QuadGio = 0
     End If
   End If
Case Else
End Select
end sub
*****************************************************************

*****************************************************************
sub IniAutoStra()
' se  sabato verifica le ore ordinarie + eccedenza fatte dal lunedi al venerdi precedenti
' se al sabato c' straordinario le ore eccedenti alle 44 (vedi sotto) vengono giustificate 
' con il giustificativo giu1
' le eventuali rimanenti vengono gestite dalla tabella straord associata al sabato


 giu1 = 18  ' imposta quale tipo di straord. 

 If WeekDay(cl.DataElab) = 7 Then   ' se siamo sabato
     lunedi = cl.DataElab - 5                 ' data del lunedi prec.
     venerdi = cl.DataElab - 1              ' data del venerdi prec.
   
   lunedi=mid(lunedi,4,3) & left(lunedi,2) & mid(lunedi,6)  ' trasforma data in formato per query 
   venerdi=mid(venerdi,4,3) & left( venerdi,2) & mid(venerdi,6) ' trasforma data in formato per query

   Query = "SELECT sum(totale) as totalone FROM totali where id_dip = " & cl.DipElab & " and data >= #"
   Query = Query  &  lunedi & "#  and data <= #" & venerdi 
   Query = Query & "# and (id_giust = 15 or id_giust =13) ;" 
  
    ' trova il totale delle ore di presenza + eccedenza
    Set  momRS = cl.miodb.openrecordset(Query , 4) 

    If momRS.RecordCount > 0 Then ' se c'  un unico record
    
      If momRS.fields("totalone") + cl.QuadGio > (44 * 60) Then  ' ore settimanali
         If cl.QuadGio > 0 Then        
           
           dagius =momRS.fields("totalone") + cl.QuadGio - 44 * 60 ' giustifica le ore eccedenti alle 44
           If dagius > cl.QuadGio Then dagius = cl.QuadGio
              If dagius > 0 Then

                 Set RSgius = cl.MioDb.OpenRecordset("giustificazioni", 1)  ' 1= DbOpenTable
                         
                 RSgius.Index = "tot_g"
                 RSgius.Seek "=", giu1, cl.DataElab, cl.DipElab

                 If RSgius.NoMatch Then
                  
                     RSgius.AddNew
                    RSgius.fields("minuti") = dagius
                 Else
                    RSgius.Edit
                    RSgius.fields("minuti") =  RSgius.fields("minuti") + dagius
                 End If

                 RSgius.fields("id_giust") = giu1
                 RSgius.fields("id_dip") = cl.DipElab
                 RSgius.fields("dta") = cl.DataElab
                 RSgius.fields("auto") = True
                 RSgius.Update
                 RSgius.Bookmark = Rsgius.LastModified
                 cl.QuadGio = cl.QuadGio - dagius     ' togli dal quadgio le ore gi giustificate 

             End If
         End If
     End If
  End If
End If
 
End sub

*****************************************************************

*****************************************************************
sub IniAutoStra()
' se fa  orario festivo infrasettimanale gli aggiunge 8 ore di giu1

dagius=480  ' minuti per 8 ore
giu1 = 174   ' id del giustificativo da aggiungere (deve essere di tipo maggiorazione)
'a= msgbox ("esci ?",vbyesno)
'if a= vbyes then exit sub

if cl.orarioelab = 7 then
  If WeekDay(cl.DataElab) <> 0 and WeekDay(cl.DataElab) <> 7  Then   ' se non siamo  domenica ne sabato
   if not cl.flagBlG then ' non fare se c' il blocco giustif
  set RsGius = cl.miodb.openrecordset("giustificazioni",1)   ' 1= DbOpenTable
    RSgius.AddNew
    RSgius.fields("minuti") = dagius
    RSgius.fields("id_giust") = giu1
    RSgius.fields("id_dip") = cl.DipElab
    RSgius.fields("dta") = cl.DataElab
    RSgius.fields("auto") = True
    RSgius.Update 
   end if

  end if
end if

End sub

*****************************************************************

*****************************************************************
sub Orione
' per gestire fasce Orione

Select Case cl.OrarioElab ' in base al tipo di orario


case 1 ' giornaliero 30 minuti di fless
giusGen = 17 ' str 20%



'msgbox cl.totord
'msgbox cl.toteccdag
'msgbox cl.totassdag

if cl.toteccdag >= 30 then
  if cl.totassdag >= 30 then
    cl.totassdag = cl.totassdag - 30 : cl.totass = cl.totass - 30
    cl.toteccdag = cl.toteccdag - 30 :cl.totEcc = cl.totEcc - 30
    cl.totord = cl.totord + 30    
  end if
end if
'msgbox cl.toteccdag
'msgbox cl.totassdag
if cl.toteccDaG > 0 then ' se c' ancora str.
  if not cl.flagBlG  then ' non fare se c' il blocco giustif

    set RsGius = cl.miodb.openrecordset("giustificazioni",1)   ' 1= DbOpenTable
    RSgius.AddNew
    RSgius.fields("minuti") = cl.totecc
    RSgius.fields("id_giust") = giusGen
    RSgius.fields("id_dip") = cl.DipElab
    RSgius.fields("dta") = cl.DataElab
    RSgius.fields("auto") = True
    RSgius.Update 
    Rsgius.close
   cl.totEccDaG =0
  end if
end if

'msgbox cl.toteccdag
'msgbox cl.totassdag


case else

end select



end sub

*****************************************************************

*****************************************************************

sub fineautostra()
' 2 ore str25% rimanenti al 30%

gius1=17 ' str 25%
gius2=18 ' str30%

Set RsGiust = cl.miodb.openrecordset("SELECT * FROM giustificazioni WHERE (id_giust = " & gius1 & " and id_dip=" & cl.DipElab & " and dta =# " & cl.DataElab2  & "#);",2) 

   If RsGiust.RecordCount > 0 Then

      totmin= rsgiust.fields("minuti")
      if totmin > 120 then
      rsgiust.edit
      rsgiust.fields("minuti")=120
      rsgiust.update
'rsgiust.close
'set rsgiust = cl.miodb.openrecordset("giustificazioni", 1)



      rsgiust.addnew
      rsgiust.fields("minuti")=totmin - 120
      rsgiust.fields("id_dip")=cl.dipelab
      rsgiust.fields("dta") = cl.dataelab
      rsgiust.fields("id_giust")= gius2    ' 30%
      rsgiust.fields("auto")= true
      rsgiust.update
     end if
   
   end if
rsgiust.close


end sub

*****************************************************************

*****************************************************************
sub PrintNumerazione()
' usare [Preferenze] Vidimato = S in dmwcfg.ini
' per non stampare intestazione su cartellino o libro giornale

Printer.FontName = "Arial"
Printer.FontSize = 12
printer.fontbold = false
printer.FontUnderline = false

printer.currenty= 150
printer.currentx= 100		
'printer.stampa " Stampa con a capo "
printer.stampa "Nuova Patavium  S.r.l."
Printer.FontSize = 10
printer.currentx= 100 
printer.stampasenzaacapo "Via S.Antonio 48/50  35030 Veggiano PD                                 - Nr.Progr: "
printer.stampa cl.mom  ' cl.mom contiene il n. progressivo
printer.currentx= 100	
printer.stampa  "P.I. 02422480281  "
printer.EndDoc
end sub
*****************************************************************

*****************************************************************
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub iniquad()
' tolleranza in uscita di 5 minuti

  
Select Case cl.OrarioElab ' in base al tipo di orario



case else
mommin = minute(cl.cltimborig2)
momore = hour(cl.cltimborig2)

if mommin mod 30 > 24 then
  mommin = mommin + 30 - (mommin mod 30)
  if mommin > 59 then
    mommin=0
    momore=momore+1
  end if
  cl.cltimb2 = timeserial(momore,mommin,0)
end if

mommin = minute(cl.cltimborig4)
momore = hour(cl.cltimborig4)

if mommin mod 30 > 24 then
  mommin = mommin + 30 - (mommin mod 30)
  if mommin > 59 then
    mommin=0
    momore=momore+1
  end if
  cl.cltimb4 = timeserial(momore,mommin,0)
end if

mommin = minute(cl.cltimborig6)
momore = hour(cl.cltimborig6)

if mommin mod 30 > 24 then
  mommin = mommin + 30 - (mommin mod 30)
  if mommin > 59 then
    mommin=0
    momore=momore+1
  end if
  cl.cltimb6 = timeserial(momore,mommin,0)
end if

mommin = minute(cl.cltimborig8)
momore = hour(cl.cltimborig8)

if mommin mod 30 > 24 then
  mommin = mommin + 30 - (mommin mod 30)
  if mommin > 59 then
    mommin=0
    momore=momore+1
  end if
  cl.cltimb8 = timeserial(momore,mommin,0)
end if

end select

end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub PrintIntestazione()
' usata nella stampa del giornale se c' Vidimato = "S"
' usare [Preferenze] Vidimato = S in dmwcfg.ini


Printer.FontName = "Arial"
Printer.FontSize = 8
printer.fontbold = false
printer.FontUnderline = false

printer.currenty= 50
printer.currentx= 50	

printer.stampaSenzaAcapo "Nome Ditta "
Printer.FontSize = 8
printer.fontbold = true
printer.stampaSenzaAcapo " altra scritta.."

Printer.FontSize = 12
printer.fontbold = false
printer.stampaSenzaAcapo " FONT 12 e Bond false "

printer.stampa " " ' per mandare a capo
printer.currentx= 50	

end sub

sub PrintNumerazioneLibro()
' usare [Preferenze] Vidimato = S in dmwcfg.ini
' per non stampare intestazione su cartellino o libro giornale

Printer.FontName = "Arial"
Printer.FontSize = 12
printer.fontbold = false
printer.FontUnderline = false

printer.currenty= 150
printer.currentx= 100		
'printer.stampa " Stampa con a capo "
printer.stampa "Nuova Patavium  S.r.l."
Printer.FontSize = 10
printer.currentx= 100 
printer.stampasenzaacapo "Via S.Antonio 48/50  35030 Veggiano PD                                 - Nr.Progr: "
printer.stampa cl.mom  ' cl.mom contiene il n. progressivo
printer.currentx= 100	
printer.stampa  "P.I. 02422480281  "

end sub


sub PrintNumerazioneCart()
' usare [Preferenze] Vidimato = S in dmwcfg.ini
' per non stampare intestazione su cartellino o libro giornale

Printer.FontName = "Arial"
Printer.FontSize = 12
printer.fontbold = false
printer.FontUnderline = false

printer.currenty= 150
printer.currentx= 100		
'printer.stampa " Stampa con a capo "
printer.stampa "Nuova Patavium  S.r.l."
Printer.FontSize = 10
printer.currentx= 100 
printer.stampasenzaacapo "Via S.Antonio 48/50  35030 Veggiano PD                                 - Nr.Progr: "
printer.stampa cl.mom  ' cl.mom contiene il n. progressivo
printer.currentx= 100	
printer.stampa  "P.I. 02422480281  "

end sub

*************************************************************************************
sub fineautostra()
' se lo str25% supera le 2 ore diventa tutto str30%

gius1=17 ' str 25%
gius2=18 ' str30%

Set RsGiust = cl.miodb.openrecordset("SELECT * FROM giustificazioni WHERE (id_giust = " & gius1 & " and id_dip=" & cl.DipElab & " and dta =# " & cl.DataElab2  & "#);",2) 

   If RsGiust.RecordCount > 0 Then

      totmin= rsgiust.fields("minuti")
      if totmin > 120 then
        rsgiust.edit
        rsgiust.fields("id_giust")= gius2    ' 30%
        rsgiust.update
      end if
   end if

rsgiust.close


end sub

*************************************************************************************

Sub fineQuad()
' IMPOSTA ANOMALIA SE LE TIMBRATURE NON SONO UGUALI A QUELLE TEORICHE
' Comprende quindi straordinari, cambi di turno, ritardi, etc...

IF cl.CLTIMB1 <> "0.00.00" THEN if TRIM(cl.OrarTeor1) <> trim(right(cl.cltimb1,8)) then  cl.anomalie = cl.anomalie or 128 
IF cl.CLTIMB2 <> "0.00.00" THEN if TRIM(cl.OrarTeor2) <> trim(right(cl.cltimb2,8)) then  cl.anomalie = cl.anomalie or 128
IF cl.CLTIMB3 <> "0.00.00" THEN if TRIM(cl.OrarTeor3) <> trim(right(cl.cltimb3,8)) then  cl.anomalie = cl.anomalie or 128
IF cl.CLTIMB4 <> "0.00.00" THEN if TRIM(cl.OrarTeor4) <> trim(right(cl.cltimb4,8)) then  cl.anomalie = cl.anomalie or 128

End Sub

*************************************************************************************






sub saldo1
  cl.mom =" aggiornato al " & date()
end sub

sub saldo2
  cl.mom = ""
end sub

sub saldo3

   anno = year(date)
   mese = month(date)
   'giorno = day(date)

   Da = dateserial(anno,mese,1) ' dal 1 del mese

   al = Date ' fino ad oggi

   mDataElabDal = mid(da,4,2) & "/" & left(da,2) & "/"  & right(da,4) ' trasformo in formato americano per la query
   mDataElabal = mid(al,4,2) & "/" & left(al,2) & "/"  & right(al,4) ' 
 
   set RsTot = cl.MioDb.OpenRecordset("SELECT sum(totale) as [totalone] FROM totali WHERE (id_giust = 15 and id_dip=" & cl.DipElab & " and data >=# " & mDataElabDal & "# and data <=# " & mdataelabal & "#);", 4)

   totaleMin = rsTot.fields("totalone")
   ore = int(totalemin/60)
   min = totalemin - (60 * ore)

   cl.mom = " Str. nel mese: "  & trim(ore) & "." & trim(min)



end sub

sub saldo4
  cl.mom =""
end sub



sub saldo5
   anno = year(date)
   mese = month(date)
   'giorno = day(date)
   GSETT=WEEKDAY(DATE)  ' Dom = 1, lun =2 ... 
   if gsett=1 then gsett=8 

         
   Da = dateadd("d", -gsett + 2 , date) ' dal luned precedente

   al = Date ' fino ad oggi

   mDataElabDal = mid(da,4,2) & "/" & left(da,2) & "/"  & right(da,4) ' trasformo in formato americano per la query
   mDataElabal = mid(al,4,2) & "/" & left(al,2) & "/"  & right(al,4) ' 
 
   set RsTot = cl.MioDb.OpenRecordset("SELECT sum(totale) as [totalone] FROM totali WHERE ((id_giust = 15 or id_giust=13) and id_dip=" & cl.DipElab & " and data >=# " & mDataElabDal & "# and data <=# " & mdataelabal & "#);", 4)

   totaleMin = rsTot.fields("totalone")
   ore = int(totalemin/60)
   min = totalemin - (60 * ore)

   cl.mom = " Ore Sett.:     "  & trim(ore) & "." & trim(min)


end sub


sub saldo6
  cl.mom =""
end sub

sub saldo7
  cl.mom =""
end sub

sub saldo8
  cl.mom =""
end sub



*************************************************************************************


sub CalcoliSuNote()
' in questo esempio cerca nei totali quante Maggiorazioni festive ci sono (id_giust 19) 
  divide per (30 perch queste magg. vengono memorizzate come fossero ore ) per ottenere
  le mezze giornate , poi moltiplica per l'indennizzo di mezza giornata (nell'esempio 15 euro)

Da = cl.dataelabdal ' per il periodo in elaborazione
al = cl.dataelabal
DataElabDal = mid(da,4,2) & "/" & left(da,2) & "/"  & right(da,4) ' trasformo in formato americano per la query
DataElabAl = mid(al,4,2) & "/" & left(al,2) & "/"  & right(al,4) ' trasformo in formato americano per la query
soglia = 0

set RsTot = cl.MioDb.OpenRecordset("SELECT sum(totale) as [totalone] FROM totali WHERE ((id_giust = 19 ) and id_dip=" & cl.DipElab & " and data >=# " & DataElabDal & "# and data <=# " & DataElabal & "#);", 4)

totaleMin = rsTot.fields("totalone")

if totaleMin > soglia then 
  printer.stampa " "
  printer.stampasenzaacapo  " Totale Maggiorazione Festiva"
  printer.fontbold = true 
  printer.stampasenzaacapo totalemin/30 * 15  ' /30 per avere le mezze giornate * Maggiorazione di mezza giornata (es 15 euro)
  printer.fontbold = false  
  printer.stampa "  Euro"
end if

RsTot.close

end sub

